(function() {
  app.controller('zixuan_mCtrl', ['$scope', '$rootScope', 'quoteApi', '$timeout', 'header_m', 'my_zxg_v', function($scope, $rootScope, quoteApi, $timeout, header_m, my_zxg_v) {
    $scope.opeated = function() {
      header_m
        .set({
          txt_r: '完成',
          fun_r: function() {
            angular.forEach($scope.hangqing_list, function(item) {
              delete item.show_del;
            });
            header_m.set({
              txt_r: '',
              fun_r: function() {}
            });
          },
        });
    };
    $scope.init = function() {
      $scope.hangqing_list = my_zxg_v.my_zxg;
      angular.forEach($scope.hangqing_list, function(item) {
        item.show_del = false;
      });
    };

    $scope.del_ = function(item) {
      delete item.show_del;
      my_zxg_v
        .set(item, { del: true })
        .then(function(res) {
          $scope.hangqing_list = res;
        });
    };


    $scope.to_top = function(item) {
      $scope.to_top_flag = true;
      my_zxg_v
        .set(item, { del: true, add: true })
        .then(function(res) {
          $scope.hangqing_list = res;
          $timeout(function() {
            $scope.to_top_flag = false;
          }, 1000);
        });
    };
  }]);
})();
